var app = getApp()
var IP = app.globalData.IP

Page({

  /**
   * 页面的初始数据
   */
  data: {
    id: '',
    selected: '',
    serviceid: '',
    imageurl: '',
    servicename: '',

    imagelist: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    //接收eventChannel传来的数据
    const eventChannel = this.getOpenerEventChannel()
    var that = this
    eventChannel.on('data', function (data) {
      that.setData({
        selected: data.selected + '>',
        serviceid: data.serviceid,
        imageurl: data.imageurl,
        servicename: data.servicename,
        id:data.id
      })
      console.log(data)
    })
    this.getimages()

  },

  getimages() {
    wx.request({
      url: `http://${IP}:8080/employee/getimages`,
      data: {
        serviceid: this.data.serviceid,
        category: '品牌'
      },
      success: res => {
        this.setData({
          imagelist: res.data
        })
        console.log(this.data.imagelist)
      }
    })
  },

  navito(e) {
    wx.navigateTo({
      url: '/pages/taximeter/detail3/detail3',
      success: res => {
        // 通过eventChannel向被打开页面传送数据
        res.eventChannel.emit('data', {
          selected: this.data.selected + e.currentTarget.dataset.selected,
          serviceid: this.data.serviceid,
          imageurl: this.data.imageurl,
          servicename: this.data.servicename,
          id:this.data.id
        })
      }
    })
  },
})